package com.digital.smartgrow.service.title;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.digital.smartgrow.dao.title.CatalogueMapper;
import com.digital.smartgrow.dto.title.Catalogue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
public class CatalogueServiceImpl implements CatalogueService{


    @Autowired
    CatalogueMapper catalogueMapper;


    @Override
    @Transactional
    public List<Catalogue> findList(Catalogue catalogue) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("idcard", catalogue.getIdcard());
        queryWrapper.eq("status", 0);
        return catalogueMapper.selectList(queryWrapper);
    }

    @Override
    @Transactional
    public void delete(Catalogue catalogue) {
        Catalogue catalogue1 = new Catalogue();
        Date date = new Date();
        catalogue1.setId(catalogue.getId()).setStatus(1).setTime(date);
        catalogueMapper.updateById(catalogue1);
    }
}
